import { useState } from 'react'
import { useRequest } from 'ahooks'
import Mock from 'mockjs'
import './App.css'

function App() {
  const getUserName = () => {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve(Mock.mock('@title(5)'))
      }, 1000)
    })
  }
  const { data, error, loading } = useRequest(getUserName)

  return (
    <div className="App">
      {error && <div>failed to load</div>}
      {loading ? <div>loading </div> : <div>username{data}</div>}
    </div>
  )
}

export default App
